<?php
/* @var $this XdvertController */
/* @var $model Xdvert */

$this->breadcrumbs=array(
	'Xdverts'=>array('index'),
	'Create',
);

$this->menu=array(
	array('label'=>'广告列表', 'url'=>array('admin')),
    array('label'=>'创建广告', 'url'=>array('create')),
);
?>

<h1>新增<?php echo $title;?></h1>
 
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'xdvert-form',
    'enableAjaxValidation'=>false,
    'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>

    <p class="note"><span class="required">*</span> 是必填内容.</p>  
    <div class="row">
        <?php if(Yii::app()->user->name=='admin'){?>  
            <?php echo $form->labelEx($model,'companyid'); ?>
            <?php echo $form->dropDownList(
                  $model,
                  'companyid', 
                CHtml::listData(
                    Company::model()->findAll(),
                    'id',
                    'title'
                )
            ); ?> 
        
        <?php }else{
            echo $form->hiddenField($model,'companyid',array('value'=>Yii::app()->user->id));
        }?>
    </div>

     <div class="row">
        <?php echo $form->labelEx($model,'title'); ?>
          <?php echo $form->textField($model,'title');?> 
        <?php echo $form->error($model,'title'); ?>
    </div>

    <div class="row"> 
        <?php echo $form->hiddenField($model,'xdtype',array('id'=>'xdtype')); ?>
    </div>
     
     <div class="row">
        <?php echo $form->labelEx($model,'thumbnails'); ?>
        <?php echo CHtml::activeFileField($model,'thumbnails'); ?>
        <?php echo CHtml::label($filetype,false); ?>
        <?php echo $form->error($model,'thumbnails'); ?>
    </div>

    <div class='row' id="pictureview"> 
        <?php  
          if(!empty($model->thumbnails)){
            echo CHtml::label("图片预览",false); 
            echo CHtml::image(Yii::app()->baseUrl.$model->thumbnails,'',array("width"=>"450px")); 
          }  
         ?>
    </div>
    <div class="row"> 
        <?php  echo CHtml::label("视频文件",false);?> 
        <?php  echo "保存完成后,将要上传的视频文件发给客服人员,请注明企业名,广告名称." ;?> 
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'url'); ?>
        <?php echo $form->textField($model,'url',array('maxlength'=>126)); ?>
        <?php echo $form->error($model,'url'); ?>
    </div>

    <div class="row" >
        <?php echo $form->checkBox($model,'usable',array('style'=>'width:16px!important;')); ?>
        <?php echo $form->label($model,'usable'); ?>
        <?php echo $form->error($model,'usable'); ?>
    </div> 

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? '新增' : '修改',array('class'=>'subButton')); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->